/*
 * config.h
 *
 *  Created on: 2011-7-25
 *      Author: minorityee1984@gmail.com
 *     Purpose: Agent Server配置
 *        Note:
 */

#ifndef CONFIG_H_
#define CONFIG_H_


#include "tinyxml.h"
#include "loki/Singleton.h"
#include "serialport/serialport.h"

using namespace chenlib;

#define DEFAULT_AGENTSERVER_CONFIG		"./config/agent_server.xml"

#define ADAPTERTYPE_SERIALPORT "serialport"
#define ADAPTERTYPE_SOCK_TCP "tcp"
#define ADAPTERTYPE_SOCK_UDP "udp"

typedef struct tagAgentServerConfig
{
	int nPort;
	int nAadapter;
	unsigned uMaxClient;
}AgentServerConfig;


class CAgentServerConfig
{
public:
	CAgentServerConfig();
	~CAgentServerConfig();
public:
	int Initialize();
	int Uninitialize();
	int GetPort() const;
	int GetAdapter() const;
	unsigned GetMaxClient() const;

protected:
	int LoadServerConfig(TiXmlNode *pServerConfig);
	int LoadAdapterConfig(TiXmlNode *pAdapterConfig);

private:
	AgentServerConfig m_config;
	SerialPortSetting m_serialport;
};

typedef Loki::SingletonHolder<CAgentServerConfig> AgentServerCfg;
#define CREATE_CONFIG_INSTANCE AgentServerCfg::Instance
#define GET_CONFIG_INSTANCE	AgentServerCfg::Instance

#endif /* CONFIG_H_ */
